var main=function(e){function t(t){for(var o,s,l=t[0],c=t[1],d=t[2],u=t[3]||[],_=0,f=[];_::-webkit-scrollbar{width:8px;height:8px;}#chat-window:not(#phone-input-list) >::-webkit-scrollbar-track{background:transparent;}#chat-window:not(#phone-input-list) >::-webkit-scrollbar-thumb{background:#a7a7a7;border-radius:8px;}#chat-window:not(#phone-input-list) >::-webkit-scrollbar-button{display:none;}#chat-window iframe{max-width:100%;}",""],e=>Object(o.e)([".frame-content{","}"],e.extraStyles));t.default=a},12:function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return a}));const o={VISITOR:"visitor",BOT:"bot",AGENT:"user"},a={AGENT:1,BOT:2}},120:function(module,__webpack_exports__,__webpack_require__){"use strict";var _constants_operators__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(72);function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class TriggerParser{constructor(e,t){_defineProperty(this,"evaluateEqualTo",(e,t)=>e.toLowerCase().trim()===t.toLowerCase().trim()),_defineProperty(this,"evaluateNotEqualTo",(e,t)=>e.toLowerCase().trim()!==t.toLowerCase().trim()),_defineProperty(this,"evaluateANDOperator",(e,t)=>e&&t),_defineProperty(this,"evaluateOROperator",(e,t)=>e||t),this.skipTriggers=["delay","skip"],this.event=e,this.params=t,this.result={},this.operatorFunction={equal:this.evaluateEqualTo,not_equal:this.evaluateNotEqualTo},this.connectorFunction={AND:this.evaluateANDOperator,OR:this.evaluateOROperator}}evaluateTriggers(){for(let e=0;e-1!==this.skipTriggers.indexOf(e.field)).forEach(e=>{this.result[e.field]=e.value})}}}getResult(){return this.result}processTriggerConditions(event){const{conditions:conditions}=event;let intermediateResults=[];for(let e=0;e{a.a.locale(e),a.a.updateLocale(e,{months:Object(i.a)(),weekdays:Object(i.c)()})}},122:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var o=n(128),a=n(8),i=n(123);const r=e=>{o.a.use(i.a).use(a.b).init({debug:!1,lng:e,fallbackLng:"en",interpolation:{escapeValue:!1},defaultNs:"chat_bubble",ns:"chat_bubble",backend:{loadPath:"".concat("https://storage.googleapis.com/swiftsell-assets/","translations/{{lng}}/{{ns}}.json")},react:{useSuspense:!1}})}},126:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));const o={USER:"user",BOT:"BOT",AGENT:"AGENT"}},127:function(e,t,n){"use strict";function o(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n0?this.items.shift():this.items}peek(){return this.items[this.items.length-1]}isEmpty(){return 0===this.items.length}size(){return this.items.length}clear(){this.items=[]}getList(){return this.items}getFirstItem(){return this.items[0]}addList(e){return this.items=[].concat(o(this.items),o(e)),this.items}}},133:function(e,t,n){e.exports=n(199)},15:function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return c}));var o=n(1);let a="",i="",r="",s=!0;const l=(e,t)=>{let{message_received:n,message_sent:o,popup_message:l}=t;a=o,i=n,r=l,s=e,e&&(new Audio(n).load(),new Audio(o).load(),new Audio(r).load())};async function c(e){if(e&&(null==e?void 0:e.type)!==o.a.ASSIGNEE_CHANGED&&s){let t=new Audio(i);"user-message"===(null==e?void 0:e.type)&&(t=new Audio(a)),"popup"===(null==e?void 0:e.type)&&(t=new Audio(r)),"muted"===e&&(t.muted=!0);try{await t.play()}catch(e){console.log(e)}}}},19:function(e,t,n){"use strict";(function(e){var o,a,i,r,s,l;n.d(t,"b",(function(){return d})),n.d(t,"c",(function(){return u})),n.d(t,"a",(function(){return p}));const c=null!==(o=window)&&void 0!==o&&null!==(a=o.document)&&void 0!==a&&null!==(i=a.getElementById("client_configurations"))&&void 0!==i&&i.value?null===JSON||void 0===JSON?void 0:JSON.parse(null===(r=window)||void 0===r||null===(s=r.document)||void 0===s||null===(l=s.getElementById("client_configurations"))||void 0===l?void 0:l.value):"",d=(null==c?void 0:c.serverAddress)||"https://app.swiftsell.biz/",u=(null==c?void 0:c.socketAddressClient)||e.env.SOCKET_ADDRESS_CLIENT||"https://app.swiftsell.biz/?user_type=visitor",p=(null==c?void 0:c.messageApiAddress)||"https://hooks.swiftsell.biz/incoming/web-message"}).call(this,n(44))},199:function(e,t,n){"use strict";n.r(t);var o=n(0),a=n.n(o),i=n(55),r=n.n(i),s=n(82),l=n.n(s),c=n(113),d=n.n(c),u=n(112),p=n(23),_=n(22),f=n(58),v=n(71),m=n(46),g=n(39),b=n(47),y=n(2),h=n.n(y),O=n(3),E=n(93),w=function(e){var t=e.theme,n=e.children;return a.a.createElement(O.c,{theme:t},a.a.createElement("div",null,n))};w.propTypes={theme:y.object,children:Object(y.oneOfType)([Object(y.arrayOf)(y.node),y.node])},w.defaultProps={theme:E.a};var S=w,A=n(45),T=n(84),I=n(89),P=n(88),C=n(97).a,j=n(7),D=n(50);const M=Object(O.g)(["0%{bottom:20px;}50%{bottom:40px;}100%{bottom:20px;}"]),x=O.f.div.withConfig({displayName:"chat-bubble-styled__Root",componentId:"sc-16yj5nm-0"})(["",""],e=>Object(O.e)(["",""],e.extraStyles)),R=Object(O.f)(D.a.div).withConfig({displayName:"chat-bubble-styled__Wrapper",componentId:"sc-16yj5nm-1"})(["position:fixed;bottom:","px;z-index:",";cursor:pointer;height:","px;width:","px;border-radius:",";display:",";animation:",";"," ",""],e=>e.theme.positions.chatBubbleBottom,e=>e.theme.zIndexes.chatBubble,e=>e.theme.sizes.chatBubble,e=>e.theme.sizes.chatBubble,e=>e.widgetIcon?"unset":"50%",e=>e.hideBubble?"none":"block",e=>e.isWidgetHoveringAnimationEnabled?Object(O.e)([""," 1.7s ease-in-out infinite;"],M):"none",e=>"left"===e.side?"\n\t\t\tleft: ".concat(e.theme.positions.chatBubbleHorizontalSpace,"px;\n\t"):"\tright: ".concat(e.theme.positions.chatBubbleHorizontalSpace,"px;"),e=>e.widgetIcon&&!e.isOpen?"background: url(".concat(e.widgetIcon,"); background-repeat: no-repeat; background-position: center; background-size: cover;"):""),L=(O.f.div.withConfig({displayName:"chat-bubble-styled__Bubble",componentId:"sc-16yj5nm-2"})(["transition:transform 0.15s linear,opacity 0.15s linear;opacity:",";transform:",";box-shadow:0 0 3px rgba(163,163,163,0.4);"],e=>e.isOpen?0:1,e=>e.isOpen?"rotate(30deg) scale(0)":"none"),O.f.div.withConfig({displayName:"chat-bubble-styled__Close",componentId:"sc-16yj5nm-3"})(["height:100%;width:100%;border-radius:50%;background-color:",";display:flex;justify-content:center;align-items:center;transition:all 1s ease-in;color:#727272;box-shadow:0 3px 2px 0 rgba(163,163,163,0.4);display:",";"],e=>e.theme.colors.closeIconGrey,e=>e.isOpen?"flex":"none")),k=Object(O.f)(D.a.div).withConfig({displayName:"chat-bubble-styled__NotificationWrapper",componentId:"sc-16yj5nm-4"})(["position:absolute;right:-18%;top:-8%;z-index:",";"],e=>e.theme.zIndexes.chatBubble+10);var N=n(6),B=n(15),U=n(5);var W=n(48),G=n(1),F=n(24),K=n(9);const H=Object(U.u)("cuid_".concat(Object(N.f)()))||Object(U.u)("cuid#".concat(Object(N.f)())),z=e=>{let{side:t,hideBubble:n}=e;const{isOpen:i,setIsOpen:r,sendCustomerDetails:s,currentConversationKey:l,isSocketConnected:c,hideBubbleOnClickOfCrossIcon:d}=Object(o.useContext)(p.a),{conversationDetails:u,fetchHistory:f,messages:v,isFileUploadPopoverOpen:b,setIsFileUploadPopoverOpen:y}=Object(o.useContext)(m.a),{setIsTyping:h}=Object(o.useContext)(g.a),O=v[v.length-1];let E=!1;var w;O&&(E=(null==O||null===(w=O.payload)||void 0===w?void 0:w.type)===G.a.FILE);const{totalConversationCount:S,fetchUnreadCounts:A,readConversationMessage:T,currentActiveScreen:D,conversationWiseReadCount:M}=Object(o.useContext)(W.a),{preference:z,onboardingPreview:V,embedMetaData:Y,hideBotOnLoad:q,setHideBotOnLoad:J}=Object(o.useContext)(_.a),[X,$]=Object(o.useState)(!1);Object(o.useEffect)(()=>(Object(U.F)({type:"chat-bubble-loaded"}),j.r.io.on("reconnect",oe),()=>{j.r&&j.r.disconnect()}),[]);const Z=z.appearance.custom_css||"",Q=()=>{var e;Object(N.a)(V)&&null!==(e=z.appearance)&&void 0!==e&&e.historyRetentionEnabled?ne(!1,()=>{f(void 0,void 0,void 0,!0),A(),$(!0)}):ne(!0,()=>{$(!0)})};Object(o.useEffect)(()=>(window.addEventListener(K.e,Q),()=>{window.removeEventListener(K.e,Q)}),[z.account_id]),Object(o.useEffect)(()=>{j.r.off("reconnect")},[u.conversation_id]),Object(o.useEffect)(()=>{if(i&&!X)if($(!0),Object.keys(Y).length&&"false"===Y.history_retention)ne(!0);else if(Object.keys(Y).length&&"true"===Y.history_retention)ne(!1,()=>{f(),A()});else if(Object(N.a)(V)&&H)if(c&&!X){var e;null!==(e=z.appearance)&&void 0!==e&&e.historyRetentionEnabled?ne(!1,()=>{f(),A()}):(h(!0),ne(!X))}else c||oe(),ne(!0);else h(!0),ne(!X)},[i,X]);const ee=()=>{document.hidden&&("visible"!==document.visibilityState||E)||(f(void 0,void 0,void 0,void 0,!0),A())};Object(o.useEffect)(()=>{const e=Object(N.a)(V)&&(!!navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)||!!navigator.userAgent&&-1!==navigator.userAgent.toLowerCase().indexOf("android"));return e&&document.addEventListener("visibilitychange",ee),E&&document.removeEventListener("visibilitychange",ee),()=>{e&&document.removeEventListener("visibilitychange",ee)}},[E]),Object(o.useEffect)(()=>{X&&D===F.b.DETAIL&&i&&l&&T(l,M[l]||0)},[i]);const te=()=>{if(Object(B.b)("muted"),d.current&&i&&J("true"),r(!i),!i&&b&&y(!1),!(v&&v.length||X||i))if($(!0),Object.keys(Y).length&&"false"===Y.history_retention)ne(!0);else if(Object.keys(Y).length&&"true"===Y.history_retention)ne(!1,()=>{f(),A()});else if(Object(N.a)(V)&&H)if(X)c||oe(),ne(!0);else{var e;null!==(e=z.appearance)&&void 0!==e&&e.historyRetentionEnabled?ne(!1,()=>{f(),A()}):(h(!0),ne(!X))}else h(!0),ne(!X)},ne=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{};e&&s(!0,!0,"initialization"),t()},oe=()=>{Object(j.c)({visitor_key:z.uuid,bot_id:z.bot_lead_id,account_id:z.account_id})};return a.a.createElement(x,{extraStyles:Z},a.a.createElement(R,{className:"chat-bubble-close-wrapper",variants:{hidden:{y:20,opacity:0},visible:{y:0,opacity:1}},initial:"hidden",animate:"visible",transition:{ease:"easeOut",duration:.8},side:t,hideBubble:n||"true"===q,widgetIcon:z.appearance.botWidgetIcon,isOpen:i,onClick:()=>{z.appearance.botWidgetIcon&&te()},onMouseOver:U.y,id:"chat-bubble-open",isWidgetHoveringAnimationEnabled:z.appearance.widget_hovering_enabled&&!X},a.a.createElement(a.a.Fragment,null,S>0&&!i&&a.a.createElement(k,{variants:{hidden:{x:20,opacity:0},visible:{x:0,opacity:1}},initial:"hidden",animate:"visible",transition:{ease:"easeOut",duration:.8}},a.a.createElement(C,{count:S>99?"".concat(99,"+"):S,onClick:te})),i?a.a.createElement(L,{isOpen:i,onClick:te,id:"chat-bubble-close"},a.a.createElement(P.a,null)):a.a.createElement(I.a,{height:65,width:65,onClick:te,iconUrl:z.appearance.botWidgetIcon}))))};z.defaultProps={side:"right",hideBubble:!1},z.propTypes={side:h.a.string,hideBubble:h.a.bool};var V,Y=z,q=n(65);const J=O.f.div.withConfig({displayName:"app-container-styled__AppContainerRoot",componentId:"sc-x0hjub-0"})(["",""],e=>Object(O.e)(["",""],e.extraStyles)),X=Object(O.f)(D.a.div).withConfig({displayName:"app-container-styled__Window",componentId:"sc-x0hjub-1"})(["position:fixed;bottom:0;top:0;left:0;right:0;box-shadow:0 3px 6px 0 rgba(0,0,0,0.16);background-color:",";display:",";"," iframe{overflow:hidden;height:100%;width:100%;}"],e=>e.theme.colors.white,e=>e.hideWindow?"none":"block",q.a.md(V||($=["\n\t\tbottom: ","px;\n\t\twidth: ","px;\n\t\theight: ","px;\n\t\ttop: auto;\n\t\tleft: auto;\n\t\tborder-radius: ",";\n\n\t\tiframe {\n\t\t\tborder-radius: ",";\n\t\t}\n\t\t","\n\t\t\t\t\n\t"],Z||(Z=$.slice(0)),V=Object.freeze(Object.defineProperties($,{raw:{value:Object.freeze(Z)}}))),e=>e.theme.positions.chatBubbleBottom+80,e=>e.theme.sizes.chatWindowWidth,e=>e.windowHeight320?e.windowHeight-115:e.theme.sizes.chatWindowHeight,e=>e.theme.radius.messageInput,e=>e.theme.radius.messageInput,e=>"left"===e.side?"\tleft: ".concat(e.theme.positions.chatBubbleHorizontalSpace+5,"px;"):"\tright: ".concat(e.theme.positions.chatBubbleHorizontalSpace+5,"px;")));var $,Z;const Q=Object(O.f)(D.a.div).withConfig({displayName:"app-container-styled__FloatingMessage",componentId:"sc-x0hjub-2"})(["position:fixed;bottom:","px;left:0;right:0;z-index:",";left:auto;"," width:","px;height:","px;max-width:","px;@media (max-width:360px){max-width:",";}iframe{overflow:hidden;height:100%;width:100%;}"],e=>e.theme.positions.chatBubbleBottom+75,e=>e.isVisible&&e.theme.zIndexes.chatBubble-5,e=>"left"===e.side?"\tleft: ".concat(e.theme.positions.floatingMessageHorizontalSpace+5,"px;"):"\tright: ".concat(e.theme.positions.floatingMessageHorizontalSpace+5,"px;"),e=>e.theme.sizes.chatWindowWidth,e=>e.isVisible?e.height:0,e=>e.maxWidth,e=>e.maxWidth<300?"".concat(e.maxWidth,"px"):"300px");var ee=n(74),te=n(4),ne=n(29);function oe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function ae(e){for(var t=1;tPromise.resolve().then(n.bind(null,112))),se=Object(o.lazy)(()=>Promise.all([n.e(0),n.e(2),n.e(6),n.e(23)]).then(n.bind(null,290))),le=Object(o.lazy)(()=>Promise.all([n.e(4),n.e(7),n.e(15),n.e(2),n.e(13)]).then(n.bind(null,207))),ce=Object(o.lazy)(()=>Promise.all([n.e(0),n.e(1),n.e(3),n.e(11),n.e(9)]).then(n.bind(null,208)));var de=()=>{var e,t,n,i,r,s,l,c,d,u,v,g;const[b,y]=Object(o.useState)(),[h,O]=Object(o.useState)(360),{isOpen:E,setIsOpen:w,currentConversationKey:I}=Object(o.useContext)(p.a),{preference:P,triggerData:C,setTriggerData:j,parentElement:D,isParentElement:M,embedMetaData:x,hideBotOnLoad:R,setHideBotOnLoad:L}=Object(o.useContext)(_.a),{messages:k}=Object(o.useContext)(m.a),{height:N,width:B}=Object(o.useContext)(f.a),[W,F]=Object(o.useState)(0),K=e=>{F(e)};Object(o.useEffect)(()=>{K(0)},[k.length]),Object(o.useEffect)(()=>{M&&w(!0)},[D]),Object(o.useEffect)(()=>{E&&M&&document.getElementById("".concat(D.parentID)).appendChild(document.getElementById("widget-chat-window"))},[E]),Object(o.useEffect)(()=>{let e=!1;var t,n,o;!e&&P&&((null==C||null===(t=C.trigger)||void 0===t?void 0:t.type)!==te.b.AUTO_OPEN&&(null==C||null===(n=C.trigger)||void 0===n?void 0:n.type)!==te.b.AUTO_OPEN_NEW||!C.isInitialTriggerPerformed||("true"===R&&L(!1),w(!0),j(ae(ae({},C),{},{isInitialTriggerPerformed:!1}))),E&&(null==C||null===(o=C.trigger)||void 0===o?void 0:o.type)===te.b.POPUP_MESSAGE&&null!=C&&C.isInitialTriggerPerformed&&j(ae(ae({},C),{},{isInitialTriggerPerformed:!1})));return()=>{e=!0}}),Object(o.useEffect)(()=>{O(360)},[C]);if(!P)return null;const H=()=>{let e=null;return document.getElementById("popup-frame")&&document.getElementById("popup-frame").contentDocument&&(e=setInterval(()=>{var t,n,o;const a=null===(t=document.getElementById("popup-frame"))||void 0===t||null===(n=t.contentDocument)||void 0===n?void 0:n.body,i=(null==a?void 0:a.querySelector(".frame-content"))&&(null==a||null===(o=a.querySelector(".frame-content"))||void 0===o?void 0:o.children)||[];if(i.length){const t=i.length;let n=0,o=0;for(let e=0;eo&&(o=i[e].children[0].clientWidth+20),n+=i[e].clientHeight;O(o<360?o:360),C.trigger.message.media.type===G.a.VIDEO?y(n+30):y(n),clearInterval(e),e=null}},50)),()=>{e&&clearTimeout(e)}},z={};P.appearance.is_branding_hidden&&(z.poweredByHeight=0);const V=ae(ae({},A.a),{},{colors:ae(ae({},A.a.colors),{},{primary:P.appearance.brand_color,text:P.appearance.text_color}),sizes:ae(ae({},A.a.sizes),z)}),q=P.appearance.custom_css||"";return a.a.createElement(S,{theme:V},a.a.createElement(Y,{side:P.appearance.chat_interface_position,hideBubble:M&&E}),/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&a.a.createElement(o.Suspense,{fallback:""},a.a.createElement(se,{visibility:"hidden"})),a.a.createElement("div",{id:"chat-bot"}),a.a.createElement(J,{extraStyles:q},a.a.createElement(X,{className:"app-container",variants:{hidden:{y:20,opacity:0,pointerEvents:"none",zIndex:-1},visible:{y:0,opacity:1,pointerEvents:"all",zIndex:A.a.zIndexes.chatBubble+20}},initial:"hidden",animate:E?"visible":"hidden",transition:{easings:["easeInOut","linear","anticipate"],type:"keyframes",duration:.3},windowHeight:N,side:P.appearance.chat_interface_position,hideWindow:M&&E,isOpen:E,headerVisible:x.header_visible},a.a.createElement(T.a,{id:"widget-chat-window",head:a.a.createElement("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"}),initialContent:'
',style:M&&E?{width:D.width,height:D.height}:{},mountTarget:"#chat-window",allowFullScreen:!0,mozallowfullscreen:"true",msallowfullscreen:"true",oallowfullscreen:"true",webkitallowfullscreen:"true",frameBorder:"0"},a.a.createElement(ee.a,{showLoader:!0},a.a.createElement(re,{extraStyles:q}),a.a.createElement(le,{windowWidth:B,currentTimeRef:W,setCurrentTimeFunction:K}))))),((null==C||null===(e=C.trigger)||void 0===e?void 0:e.type)===te.b.POPUP_MESSAGE||(null==C||null===(t=C.trigger)||void 0===t?void 0:t.type)===te.b.LAST_MESSAGE)&&(C.isInitialTriggerPerformed||C.isTriggerPerformed)&&!Object.keys(x).length&&!M&&"true"!==R&&((oe=C.trigger.message).text||(null==oe||null===(ie=oe.media)||void 0===ie?void 0:ie.url)||(null==oe||null===(de=oe.media)||void 0===de?void 0:de.type)||"")&&a.a.createElement(Q,{variants:{hidden:{y:20,opacity:0},visible:{y:0,opacity:1}},initial:"hidden",animate:"visible",transition:{ease:"easeOut",duration:.5},side:P.appearance.chat_interface_position,height:b,maxWidth:null!==($=C.trigger.message)&&void 0!==$&&$.media.url&&C.trigger.message.text?332:null!==(Z=C.trigger.message)&&void 0!==Z&&Z.media.url&&!C.trigger.message.text?306:Object(ne.d)(C.trigger.message.text,ne.b.ANONYMOUS_IMAGE_TAG)?360:h,isVisible:C.isInitialTriggerPerformed||C.isTriggerPerformed,className:"widget-floating-message"},a.a.createElement(T.a,{onLoad:e=>{H()},initialContent:'',id:"popup-frame",onMouseOver:U.y},a.a.createElement(ee.a,null,a.a.createElement(ce,{extraStyles:q,onLoadPopupIframe:H,isVisible:C.isInitialTriggerPerformed||C.isTriggerPerformed,onClose:()=>{j(ae(ae({},C),{},{isInitialTriggerPerformed:!1,isTriggerPerformed:!1}))},conversationKey:null==C||null===(n=C.trigger)||void 0===n||null===(i=n.message)||void 0===i?void 0:i.conversationKey,botPublishKey:null==C||null===(r=C.trigger)||void 0===r||null===(s=r.message)||void 0===s?void 0:s.botPublishKey,side:P.appearance.chat_interface_position,message:Object(ne.d)(C.trigger.message.text,ne.b.ANONYMOUS_IMAGE_TAG)?C.trigger.message.text.replace("<","<").replace(">",">"):C.trigger.message.text,media:C.trigger.message.media,tempMessage:null==C||null===(l=C.trigger)||void 0===l||null===(c=l.message)||void 0===c?void 0:c.tempMessage,currentConversationKey:I,avatar:null==C||null===(d=C.trigger)||void 0===d||null===(u=d.message)||void 0===u?void 0:u.avatar,assigneeName:null!=C&&C.isInitialTriggerPerformed?P.appearance.messenger_prompt:null==C||null===(v=C.trigger)||void 0===v||null===(g=v.message)||void 0===g?void 0:g.assignee,setCurrentTimeFunction:K})))));var $,Z,oe,ie,de};var ue=()=>a.a.createElement(v.b,null,a.a.createElement(b.b,null,a.a.createElement(g.b,null,a.a.createElement(W.b,null,a.a.createElement(m.b,null,a.a.createElement(de,null))))));var pe=e=>a.a.createElement(a.a.Fragment,null,a.a.createElement(u.default,null),a.a.createElement(f.b,null,a.a.createElement(_.b,e,a.a.createElement(p.b,null,a.a.createElement(ue,null)))));l.a.start({apiKey:"{{XXXXXXXXXXXXXX-BugsNag API Key-XXXXXXXXXXXXXX}}",plugins:[new d.a],appType:"Chat Bubble V3",releaseStage:"App",enabledReleaseStages:["App"]});{const e=l.a.getPlugin("react").createErrorBoundary(a.a);r.a.render(a.a.createElement(e,null,a.a.createElement(pe,null)),document.getElementById("chat-bot"))}},22:function(e,t,n){"use strict";var o=n(76);n.d(t,"a",(function(){return o.a})),n.d(t,"b",(function(){return o.b}))},23:function(e,t,n){"use strict";var o=n(75);n.d(t,"a",(function(){return o.a})),n.d(t,"b",(function(){return o.b}))},24:function(e,t,n){"use strict";n.d(t,"b",(function(){return C})),n.d(t,"a",(function(){return j}));var o=n(0),a=n.n(o),i=n(56),r=n.n(i),s=n(32),l=n.n(s),c=n(19),d=n(7),u=n(6),p=n(5),_=n(22),f=n(23),v=n(15),m=n(4),g=n(43),b=n(1),y=n(12),h=n(29),O=n(47),E=n(39),w=n(34),S=n(63),A=n(96);function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function I(e){for(var t=1;t{const{setSessionData:t,currentConversationKey:n,isOpen:i,connectionKey:s,newSessionRequiredData:T,javascriptExectionMap:P}=Object(o.useContext)(f.a),{setAgentInfo:D}=Object(o.useContext)(O.a),{setAgentInfo:M}=Object(o.useContext)(E.a),x=Object(o.useRef)(null),{resetHideInput:R,preference:L,onboardingPreview:k,setTriggerData:N,triggerData:B}=Object(o.useContext)(_.a),[U,W]=Object(o.useState)({}),[G,F]=Object(o.useState)(!1),[K,H]=Object(o.useState)({}),[z,V]=Object(o.useState)(0),[Y,q]=Object(o.useState)(C.DETAIL),[J,X]=Object(o.useState)(!1),[$,Z]=Object(o.useState)(!0),[Q,ee]=Object(o.useState)(!1),te=Object(o.useRef)(!0),ne=Object(o.useRef)(s),oe=Object(o.useRef)(0),ae=Object(o.useRef)(null),ie=Object(o.useRef)(!1),re=Object(o.useRef)(null),[se,le]=Object(o.useState)({}),ce=Object(o.useRef)(C.DETAIL),de=Object(o.useRef)(n),ue=Object(o.useRef)(!1),pe=function(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];ne.current&&(n&&Object(d.d)(e,t),V(t=>t-(K[e]||0)),H(t=>I(I({},t),{},{[e]:0})),W(t=>I(I({},t),{},{[e]:I(I({},t[e]),{},{visitor_unread_messages_count:0})})))};Object(o.useEffect)(()=>{te.current=$},[$]),Object(o.useEffect)(()=>{x.current=T},[T]),Object(o.useEffect)(()=>{ne.current=s},[s]),Object(o.useEffect)(()=>{de.current=n},[n]);const _e=Object(o.useCallback)(async()=>{try{const e=null==L?void 0:L.uuid;if(e){const t="".concat(c.b,"v1/conversations/visitor/").concat(e,"/unread-count?origin=chat_widget&conversation_wise_count=true");ee(!0);const n=await fetch(t),o=await n.json();ee(!1),o.ok&&(V(o.total_counts),H(o.conversations))}}catch(e){console.error("Error occured while loading conversation count",e)}},[L]),fe=Object(o.useRef)(r()((e,t)=>{pe(e,t)},500)).current;Object(o.useEffect)(()=>{ce.current=Y,Y===C.LIST&&oe.current++,1===oe.current&&ve()},[Y]),Object(o.useEffect)(()=>{L&&!ie.current&&Object(u.a)(k)&&(ie.current=!0,_e())},[_e,L]),Object(o.useEffect)(()=>{re.current=i,re.current&&(ue.current=!1,N({isInitialTriggerPerformed:!1,trigger:{},isTriggerPerformed:!1}))},[i]);const ve=async e=>{try{e||F(!0);const t="".concat(c.b,"v1/accounts/").concat(L.account_id,"/conversations");let n={origin:"chat_widget",limit:25,is_order_by_asc:!1,visitor_key:L.uuid};e&&(n=I(I({},n),{},{search_after:ae.current}));const o=await fetch(t,{method:"POST",body:JSON.stringify(n),headers:{"Content-type":"application/json"}}),a=await o.json();a.ok&&(ae.current=a.search_after,Z(a.conversations.length>=25),W(e=>{return I(I({},e),(t=a.conversations,n=e,t.reduce((e,t)=>I(I({},e),{},{[t.thread_key]:I(I({},t),e[t.thread_key])}),n)));var t,n})),e||F(!1)}catch(e){console.error("Error occured while fetching conversations",e)}},me=e=>{if(!re.current&&!e.isSent&&!e.payload.is_closed&&!1!==(null==e?void 0:e.isClosed)&&0!==(null==e?void 0:e.end_dialog_sequence)){var t,o,a,i,r,s;if((null==e||null===(t=e.payload)||void 0===t||null===(o=t.assignee)||void 0===o||null===(a=o.to)||void 0===a?void 0:a.type)===y.a.AGENT)return;if((null==e?void 0:e.payload.type)===b.a.FEEDBACK)return;const h=(null==e||null===(i=e.payload)||void 0===i?void 0:i.type)===b.a.GOOGLE_ANALYTICS;if((null==e||null===(r=e.payload)||void 0===r?void 0:r.type)===b.a.JAVASCRIPT||(null==e||null===(s=e.payload)||void 0===s?void 0:s.type)===b.a.GOOGLE_ANALYTICS){var c,u,_,f;const t=null==e||null===(c=e.payload)||void 0===c||null===(u=c.payload)||void 0===u?void 0:u.script,o=l()(null==e?void 0:e.timestamp).utc().format("YYYY-MM-DDTHH:mm:ss.SSSSSS[+00:00]");var v,g;if(!P.current.includes(null==e||null===(_=e.payload)||void 0===_||null===(f=_.payload)||void 0===f?void 0:f.id))P.current.push(null==e||null===(v=e.payload)||void 0===v||null===(g=v.payload)||void 0===g?void 0:g.id),Object(S.a)(t||"",h,(function(t){var o,a,i,r;let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var l,c;null!=e&&null!==(o=e.payload)&&void 0!==o&&null!==(a=o.payload)&&void 0!==a&&a.id&&(t.id=null==e||null===(l=e.payload)||void 0===l||null===(c=l.payload)||void 0===c?void 0:c.id);Object(d.a)(I(I({},x.current),{},{connection_key:Object(p.t)(),message:{type:s?b.a.CALENDLY_RESPONSE:h?b.a.GOOGLE_ANALYTICS_RESPONSE:b.a.JAVASCRIPT_RESPONSE,data:h?{id:null==e||null===(i=e.payload)||void 0===i||null===(r=i.payload)||void 0===r?void 0:r.id}:t},conversation_key:n}))}),I(I({},T),{},{connection_key:Object(p.t)(),conversation_key:null==e?void 0:e.conversation_key,status:{event:"read",timestamp:o}}))}else(e=>{let{text:t,type:n,url:o,temporaryMsg:a,conversationKey:i,botPublishKey:r,popupAvatar:s,assigneeName:l}=e;ue.current=!0,N(I(I({},B),{},{isTriggerPerformed:!0,trigger:{message:{botPublishKey:r,conversationKey:i,tempMessage:a||"",text:t,media:{type:n,url:o},avatar:s,assignee:l},type:m.b.LAST_MESSAGE}}))})(Object(p.v)(e,L))}};return a.a.createElement(j.Provider,{value:{conversationsList:U,conversationWiseUndreadCounts:K,totalConversationCount:z,fetchUnreadCounts:_e,currentActiveScreen:Y,openConversationListView:()=>{R(!1),q(C.LIST)},openConversationDetailView:e=>{const n=U[e],o=null==n?void 0:n.assignee;t(e,null==n?void 0:n.publish_key),o&&o.type_id!==y.b.BOT&&o.type!==y.a.BOT?(D({assignee:{to:{email:o.email,id:o.id,first_name:o.name,last_name:"",image_url:o.image_url}}}),M({name:o.name,email:o.email,user_type_id:o.type_id,image_url:o.image_url})):(D(null),M(null)),R(L.appearance.is_hide_input_disabled_originalValue),q(C.DETAIL)},isLoading:G,setCurrentActiveScreen:q,fetchConversationList:ve,handleInfiniteScroll:async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];te.current&&(!e&&J||(X(!0),await ve(!0),X(!1)))},isMoreLoading:J,hasMoreConversations:$,handleLastMessage:(e,t)=>{var o,a;(null==e||null===(o=e.sender)||void 0===o?void 0:o.type)!==y.a.VISITOR&&me(e);const r=U[e.conversation_key]||{};r.thread_key=e.conversation_key,r.publish_key=e.publish_key;const s=(null===(a=U[e.conversation_key])||void 0===a?void 0:a.message)||"",l=((e,t)=>{var n,o,a,i,r,s,l,c,d,u,p,_,f,v,m,g,y,O,E,S,A,T,I,P,C,j,D,M,x,R,L,k,N,B,U,W,G,F,K,H,z,V,Y,q,J,X,$,Z,Q,ee,te,ne,oe,ae,ie,re,se,le,ce,de,ue;if((null==e?void 0:e.type)===b.a.STATUS)return t;if((null==e||null===(n=e.payload)||void 0===n?void 0:n.type)===b.a.FEEDBACK)return t;if((null==e||null===(o=e.message)||void 0===o||null===(a=o.data)||void 0===a?void 0:a.type)===b.a.WHATSAPP_FLOW)return t;if((null==e||null===(i=e.payload)||void 0===i?void 0:i.type)===b.a.WHATSAPP_FLOW)return null==e||null===(ee=e.payload)||void 0===ee||null===(te=ee.payload)||void 0===te?void 0:te.title;if((null==e||null===(r=e.message)||void 0===r||null===(s=r.data)||void 0===s?void 0:s.type)===b.a.WHATSAPP_CATALOG)return t;if((null==e||null===(l=e.payload)||void 0===l?void 0:l.type)===b.a.WHATSAPP_CATALOG)return null==e||null===(ne=e.payload)||void 0===ne||null===(oe=ne.payload)||void 0===oe?void 0:oe.text;if((null==e||null===(c=e.message)||void 0===c?void 0:c.type)==="".concat(b.a.AI_STUDIO,".response"))return(null==e?void 0:e.message.data.response.text)||t;if((null==e||null===(d=e.message)||void 0===d?void 0:d.type)===b.a.STREAMING_RESPONSE)return(null==e||null===(ae=e.message)||void 0===ae||null===(ie=ae.data)||void 0===ie||null===(re=ie.response)||void 0===re?void 0:re.text)||t;if((null==e||null===(u=e.payload)||void 0===u?void 0:u.type)===b.a.STREAMING)return t;if((null==e||null===(p=e.payload)||void 0===p||null===(_=p.payload)||void 0===_?void 0:_.type)===b.a.INFO)return e.payload.payload.info.title;if(null!=e&&null!==(f=e.payload)&&void 0!==f&&f.assignee)return t;if((null==e||null===(v=e.payload)||void 0===v?void 0:v.type)===b.a.CALENDAR_SLOTS&&2===(null==e||null===(m=e.payload)||void 0===m?void 0:m.version))return w.a.SELECT_SLOT_SMALL_CASE;if((null==e||null===(g=e.payload)||void 0===g?void 0:g.type)===b.a.CALENDAR_SLOTS&&null!=e&&null!==(y=e.payload)&&void 0!==y&&null!==(O=y.payload)&&void 0!==O&&null!==(E=O.slot_selection)&&void 0!==E&&E.title)return null==e||null===(se=e.payload)||void 0===se||null===(le=se.payload)||void 0===le||null===(ce=le.slot_selection)||void 0===ce?void 0:ce.title;if(Object(h.d)(null==e||null===(S=e.payload)||void 0===S||null===(A=S.payload)||void 0===A?void 0:A.text,h.b.ANONYMOUS_IMAGE_TAG))return null==e||null===(de=e.payload)||void 0===de||null===(ue=de.payload)||void 0===ue?void 0:ue.text.replace("<","<").replace(">",">");if((null==e||null===(T=e.payload)||void 0===T?void 0:T.type)===b.a.JAVASCRIPT||(null==e||null===(I=e.payload)||void 0===I?void 0:I.type)===b.a.GOOGLE_ANALYTICS)return t;if((null==e||null===(P=e.message)||void 0===P?void 0:P.type)===b.a.JAVASCRIPT_RESPONSE||(null==e||null===(C=e.message)||void 0===C?void 0:C.type)===b.a.GOOGLE_ANALYTICS_RESPONSE)return t;if((null==e||null===(j=e.payload)||void 0===j?void 0:j.type)===b.a.CARD_VIEW||(null==e||null===(D=e.payload)||void 0===D?void 0:D.type)===b.a.IMAGE_CAROUSEL)return h.a.CAROUSEL_CONTENT;if((null==e||null===(M=e.message)||void 0===M?void 0:M.type)===b.a.FORM_RESPONSE){const{fields:t}=e.message.data;return"".concat(t[0].label,": ").concat(t[0].value)}return null!=e&&null!==(x=e.payload)&&void 0!==x&&null!==(R=x.payload)&&void 0!==R&&R.text?e.payload.payload.text:null!=e&&null!==(L=e.message)&&void 0!==L&&null!==(k=L.data)&&void 0!==k&&k.body?e.message.data.body:null!=e&&null!==(N=e.payload)&&void 0!==N&&null!==(B=N.payload)&&void 0!==B&&null!==(U=B.document)&&void 0!==U&&U.file_name?e.payload.payload.document.file_name:null!=e&&null!==(W=e.payload)&&void 0!==W&&null!==(G=W.payload)&&void 0!==G&&null!==(F=G.image)&&void 0!==F&&F.file_name?e.payload.payload.image.file_name:null!=e&&null!==(K=e.payload)&&void 0!==K&&null!==(H=K.payload)&&void 0!==H&&null!==(z=H.video)&&void 0!==z&&z.file_name?e.payload.payload.video.file_name:null!=e&&null!==(V=e.payload)&&void 0!==V&&null!==(Y=V.payload)&&void 0!==Y&&null!==(q=Y.audio)&&void 0!==q&&q.file_name?e.payload.payload.audio.file_name:null!=e&&null!==(J=e.payload)&&void 0!==J&&null!==(X=J.payload)&&void 0!==X&&null!==($=X.voice)&&void 0!==$&&$.file_name?e.payload.payload.voice.file_name:null!=e&&null!==(Z=e.payload)&&void 0!==Z&&null!==(Q=Z.payload)&&void 0!==Q&&Q.title?e.payload.payload.title:t})(e,s);var _,f;(r.message=l,l!==s&&(r.last_message_at=e.timestamp),e.assignee&&(r.assignee=I(I({},e.assignee),{},{name:"".concat(e.assignee.first_name).concat(e.assignee.last_name?" ".concat(e.assignee.last_name):"")})),((e,t)=>{var o,a,i,r,s,l,c,d,_,f;if(t===g.c.ASSIGNEE_CHANGE)return!1;const h=e.type===m.a.FAQ_FEEDBACK||p.x.includes(null==e||null===(o=e.payload)||void 0===o?void 0:o.type)||(null==e||null===(a=e.payload)||void 0===a||null===(i=a.payload)||void 0===i?void 0:i.sub_type)===b.a.AI_STUDIO_RESPONSE;return(null==e?void 0:e.sender.type)===y.a.VISITOR||(null==e||null===(r=e.payload)||void 0===r||null===(s=r.payload)||void 0===s?void 0:s.sub_type)===b.a.AI_STUDIO_RESPONSE||(e.payload||{}).is_closed||h?!((null==e||null===(l=e.message)||void 0===l?void 0:l.type)!==b.a.STREAMING_RESPONSE&&(null==e||null===(c=e.message)||void 0===c?void 0:c.type)!=="".concat(b.a.AI_STUDIO,".response")||null==e||null===(d=e.message)||void 0===d||null===(_=d.data)||void 0===_||null===(f=_.response)||void 0===f||!f.text):((Object(u.a)(k)||e.conversation_key===n)&&Object(v.b)(e),!0)})(e,t)&&"assignee"!==t&&(i&&ce.current===C.DETAIL&&e.conversation_key===de.current?le(t=>{const n=t[e.conversation_key]||0;return fe(e.conversation_key,n+1),I(I({},t),{},{[e.conversation_key]:n+1})}):(H(t=>{const n=t[e.conversation_key]||0;return I(I({},t),{},{[e.conversation_key]:n+1})}),V(e=>e+1))),W(t=>I(I({},t),{},{[e.conversation_key]:r})),ce.current===C.LIST)&&((null==e||null===(_=e.payload)||void 0===_?void 0:_.type)===b.a.STREAMING?function(e){var t,n;let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},a="",i="";const r=e=>{o(a,i,e)},s="".concat(c.b,"v1/service-call/streaming"),l={dialog_key:Number(null==e||null===(t=e.payload)||void 0===t||null===(n=t.payload)||void 0===n?void 0:n.dialog_key),conversation_key:null==e?void 0:e.conversation_key};fetch(s,{method:"POST",body:JSON.stringify(l),headers:{"Content-type":"application/json"}}).then(async t=>{var n;if(!t.ok){throw await t.json()}const o=null===(n=t.body)||void 0===n?void 0:n.getReader(),s=new TextDecoder;for(;;){const t=await(null==o?void 0:o.read());if(null!=t&&t.done){a&&Object(v.b)(e),r();break}const n=s.decode(null==t?void 0:t.value).split("\n");n.splice(-1),n.forEach(t=>{try{var n,o,r,s;const l={response:null===(n=JSON.parse(t))||void 0===n?void 0:n.data},c=Object(A.a)(l,null==e||null===(o=e.payload)||void 0===o||null===(r=o.payload)||void 0===r?void 0:r.streaming_field_path);i=null===(s=JSON.parse(t))||void 0===s?void 0:s.data,void 0!==c&&(a+="string"!=typeof c?JSON.stringify(c):c)}catch(e){a+=t,i=t}})}}).catch(e=>{r(500===(null==e?void 0:e.status)||"AbortError"===e.name)})}(e,(t,n,o)=>{var a,i;Object(d.a)(I(I({},T),{},{connection_key:Object(p.t)(),message:{type:"".concat(b.a.STREAMING,".response"),data:{response:{ok:!0,text:t,body:n},id:null==e||null===(a=e.payload)||void 0===a||null===(i=a.payload)||void 0===i?void 0:i.id,status:o?"failure":"success"}}}),!1)}):(null==e||null===(f=e.payload)||void 0===f?void 0:f.type)===b.a.AI_STUDIO&&function(e){var t,n,o,a,i,r,s,l;let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},d="";const u="".concat(null==e||null===(t=e.payload)||void 0===t||null===(n=t.payload)||void 0===n?void 0:n.api),p=null==e||null===(o=e.payload)||void 0===o||null===(a=o.payload)||void 0===a?void 0:a.body;delete p.payload,fetch(u,{headers:null==e||null===(i=e.payload)||void 0===i||null===(r=i.payload)||void 0===r?void 0:r.header,method:null==e||null===(s=e.payload)||void 0===s||null===(l=s.payload)||void 0===l?void 0:l.method,body:JSON.stringify(p)}).then(async t=>{var n;if(Object(v.b)(e),!t.ok)throw new Error;const o=null===(n=t.body)||void 0===n?void 0:n.getReader(),a=new TextDecoder;for(;;){const t=await(null==o?void 0:o.read());if(null!=t&&t.done){var i,r,s;c(d,null==e||null===(i=e.payload)||void 0===i||null===(r=i.payload)||void 0===r||null===(s=r.body)||void 0===s?void 0:s.query);break}d+=a.decode(null==t?void 0:t.value)}}).catch(t=>{var n,o,a;c(d,null==e||null===(n=e.payload)||void 0===n||null===(o=n.payload)||void 0===o||null===(a=o.body)||void 0===a?void 0:a.query)})}(e,(e,t)=>{const n=!e;Object(d.a)(I(I({},T),{},{connection_key:Object(p.t)(),message:{type:"".concat(b.a.AI_STUDIO,".response"),data:{response:{ok:!n,text:e,query:t}}}}),!1)}))},readConversationMessage:pe,unreadsLoading:Q,conversationWiseReadCount:se,setConversationWiseReadCount:le,currentActiveScreenRef:ce,messageTriggeredInPopup:ue}},e.children)}},29:function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return s})),n.d(t,"d",(function(){return d})),n.d(t,"c",(function(){return _}));var o=n(34);const a=["image","video","document","audio","voice"],i=["image"],r={IMAGE_TAG:/]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/gim,IFRAME_TAG:/]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/gim,VIDEO_TAG:/].?controls|<\/video>/gim,AUDIO_TAG:/].?controls|<\/audio>/gim,VOICE_TAG:/].?controls|<\/voice>/gim,IFRAME_SRC:/src="([^"]+)"/gim,SOURCE_YOUTUBE:/\byoutube/gim,HTML_TAGS:/(<([^>]+)>)/gi,URL_OR_VARIABLE:/^https?:\/\/([\w\d\-]+\.)+\w{2,}(\/.*)?(?=\w+\.\w{3,4}$).+|^#.*#$/,ANONYMOUS_IMAGE_TAG:/<[iI][mM][gG]([^>]*[^/>])/gim},s={IFRAME_CONTENT:"EMBEDDABLE",IMAGE_FILE:"IMAGE",CAROUSEL_CONTENT:"CAROUSEL",VIDEO_FILE:"VIDEO",AUDIO_FILE:"AUDIO",CODE_SNIPPET:"CODE SNIPPET",STREAMING:"STREAMING"};function l(e){try{return JSON.parse(e),!0}catch(e){return!1}}const c=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{const[o]=e.payload.messages;return o&&"info"===o.type?o.info.title:o&&2===e.payload.version&&a.includes(o.type)?n?[o[o.type]]:t?i.includes(o.type)?'msg'):'').concat(o[o.type].file_name,""):o[o.type].file_name:o.text}catch(e){return""}};function d(e,t){return!(null==e||!e.match(t))}function u(e){const t=JSON.parse(e.replace(/\\/gim,""));return t.hasOwnProperty("title")&&""!==t.title?function(e){switch(e.type){case"form.response":{const{fields:t}=e;return"".concat(t[0].label,": ").concat(t[0].value)}case"options":return e.text||e.message;case"slider":case"button":case"calendar":case"custom_phone_input":case"file_upload":case"form":{let t=e.title||e.message||e.text;try{t=JSON.parse(t).message||JSON.parse(t).title}catch(e){}return t}case"image_carousel":case"cardview":return CONSTANTS.CONVERSATION_CONSTANT.CAROUSEL_CONTENT;case"email":return e.text.replace(CONSTANTS.REGEX_PATTERNS.HTML_TAGS,"");case"name":case"phone":case"text":return e.text.replace(CONSTANTS.REGEX_PATTERNS.HTML_TAGS,"");case"slider.response":return e.message||e.text;case"files":{const{files:t}=e;return t[0].filename}case"file":{const{message:t}=JSON.parse(e.text);return t}case"file.response":{let t="";try{const{files:n}=e;t=n[0].filename}catch(e){}return t}case"appointment_booking":case"delay":return null}if(e.message&&e.message.data){if("file_upload.response"===e.message.type)return e.message.data.files[0].filename;if("form.response"===e.message.type)return"".concat(e.message.data.fields[0].label,": ").concat(e.message.data.fields[0].value)}if(e.message&&e.message.data&&e.message.data.body)return e.message.data.body;try{return l(e.replace(/\\/gim,""))?u(e):d(e,r.IMAGE_TAG)?s.IMAGE_FILE:d(e,r.VIDEO_TAG)?s.VIDEO_FILE:d(e,r.AUDIO_TAG)?s.AUDIO_FILE:e.replace(r.HTML_TAGS,"")}catch(e){return""}}(t.title):t.hasOwnProperty("text")?JSON.parse(e).text:isNaN(e)?s.CODE_SNIPPET:e.replace(r.HTML_TAGS,"")}function p(e){if(!e)return"";if(e.type)switch(e.type){case"calendar":case"slider":case"file_upload":case"form":return e.payload.title;case"send_message":return c(e);case"carousel":case"image_carousel":return s.CAROUSEL_CONTENT;case"text":case"name":case"email":case"phone":return e.payload.text.replace(r.HTML_TAGS,"");case"button":return e.payload.title.replace(r.HTML_TAGS,"");case"delay":return"";case"list":return e.payload.body.text}if(e.message&&e.message.data){if("file_upload.response"===e.message.type)return e.message.data.files[0].filename;if("form.response"===e.message.type)return"".concat(e.message.data.fields[0].label,": ").concat(e.message.data.fields[0].value)}if(e.message&&e.message.data&&e.message.data.body)return e.message.data.body;try{return l(e.replace(/\\/gim,""))?u(e):d(e,r.IMAGE_TAG)?s.IMAGE_FILE:d(e,r.VIDEO_TAG)?s.VIDEO_FILE:d(e,r.AUDIO_TAG)||d(e,r.VOICE_TAG)?s.AUDIO_FILE:e.replace(r.HTML_TAGS,"")}catch(e){return""}}const _=e=>{let t=p(e);if(d(e,r.ANONYMOUS_IMAGE_TAG))return s.IMAGE_FILE;if(l(e)){const i=JSON.parse(e);if("cardview"===i.type)t=s.CAROUSEL_CONTENT;else if("options"===i.type)t=p(i.text);else if("calendar"===i.type||"custom_phone_input"===i.type)t=p(JSON.parse(i.text).title);else if("text"===i.type||"file"===i.type)if(t=p(i.text),"text"===i.type&&l(t.replace(/\\/gim,""))&&(a=JSON.parse(t.replace(/\\/gim,"")),"[object Array]"===Object.prototype.toString.call(a))){const e=JSON.parse(t.replace(/\\/gim,""));t=p(e[e.length-1].text)?p(e[e.length-1].text):p(e[e.length-2].text)}else"file"===i.type&&l(i.text)&&2===JSON.parse(i.text).version&&(t=p(JSON.parse(i.text).message));else if("form"===i.type)t=p(JSON.parse(i.text).message);else if("form.response"===i.type){const{fields:e}=i;t="".concat(e[0].label,": ").concat(e[0].value)}else if("slider"===i.type)t=p(JSON.parse(i.text).message);else if("slider.response"===i.type)t=p(i.text);else if("file.response"===i.type){const{files:e}=i;t=p(e[0].filename)}else if("list"===i.type)t=p(i.title);else if("send_message"===i.type){t=p({payload:{messages:[JSON.parse(i.text)],version:2},type:"send_message"})}else if("appointment_booking"===i.type){var n;t=2===(null==i||null===(n=i.payload)||void 0===n?void 0:n.version)?o.a.SELECT_SLOT_SMALL_CASE:i.payload.slot_selection.title}else t=p(e)}else t=p(e);var a;return t}},30:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));const o={PREVIEW:"preview",PUBLISH:"publish"}},34:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));const o={MESSENGER_HINT:"Send a message",SELECT_SLOT:"SELECT YOUR SLOT",CAROUSEL:"CAROUSEL",SELECT_SLOT_SMALL_CASE:"Select your slot"}},35:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));const o={IMG_TAG:/]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/gim,IFRAME_TAG:/]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/gim,VIDEO_TAG:/]*?>/gim,AUDIO_TAG:/]*?>/gim,VOICE_TAG:/]*?>/gim,EMAIL_PATTERN:/(mailto:)?([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi,EMAIL_MAILTO_PATTERN:/]*((mailto:)?([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+))[^>]*>.*<\/a>/gim,WITH_PROTOCOL_PATTERN:/(?!]*>.*)((?:http(s)?:\/\/)[\w-]+(?:\.[\w]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.%]+)(?!.*[^<]*<\/a>)/gim,WITHOUT_PROTOCOL_PATTERN:/(?!]*>.*)([\w-]+\.(?:[\w]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=%]+)(?!.*[^<]*<\/a>)/gim,SRC_PATTERN:/((?:http(s)?:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&\(\)\*\+,;=.]+)/gim,ANCHOR_PATTERN:/]+>([^<]+)<\/a>/}},39:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return _}));var o=n(0),a=n.n(o),i=n(64),r=n.n(i),s=n(2),l=n.n(s),c=n(7),d=n(23);const u=Object(o.createContext)({isTyping:!1,agentInfo:null,setIsTyping:()=>{},setAgentInfo:()=>{}});function p(e){let{children:t}=e;const[n,i]=Object(o.useState)(!0),[s,l]=Object(o.useState)(null),{currentConversationKey:p}=Object(o.useContext)(d.a),[_,f]=Object(o.useState)(null),v=Object(o.useRef)(null),m=Object(o.useRef)(r()(e=>i(e),500)).current;Object(o.useEffect)(()=>{l(p)},[p]),Object(o.useEffect)(()=>{const e=e=>{const t=e.conversation_id||e.conversation_key;if(p!==t)return;"agent"===e.sender.type&&f(e.sender);const n=()=>{i(!0),l(t),v.current=setTimeout(()=>{if(clearTimeout(v.current),v.current=null,"agent"===e.sender.type)return f(e.sender),void i(!1);_&&f(null)},2e3)};v.current?(clearTimeout(v.current),v.current=null,n()):n()};return c.o(e),c.h(e),()=>{v.current&&clearTimeout(v.current)}});return a.a.createElement(u.Provider,{value:{isTyping:n,setIsTyping:function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?i(e):m(e)},conversationKey:s,setConversationKey:l,agentInfo:_,setAgentInfo:f}},t)}p.propTypes={children:l.a.node};var _=p},4:function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return a}));const o={CUSTOMER_DETAILS:"customer-details",TYPING:"typing",AGENT_TYPING:"agent_typing",BOT_MESSAGE:"message",ASSIGNEE_CHANGED:"assignee",MESSAGE:"message",REGISTER:"register",VISITOR_TYPING:"visitor_typing",STATUS_CHANGED:"status",FAQ_FEEDBACK:"faq-feedback",VISITOR_JOIN:"visitor_join",VISITOR_MESSAGE:"visitor_message",USER_STATUS:"user_status",VISITOR_REJOIN:"visitor_rejoin",EVENT:"events",DELAY:"delay",VISITOR_MESSAGE_READ:"visitor_message_read",AI_STUDIO:"ai_studio"},a={AUTO_OPEN:"auto_open",AUTO_OPEN_NEW:"auto-open",POPUP_MESSAGE:"popup_message",LAST_MESSAGE:"last_message"}},42:function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"d",(function(){return i})),n.d(t,"a",(function(){return r})),n.d(t,"c",(function(){return s}));var o=n(8);const a={BY:"by",IS_TYPING:"is typing",MONTHS:"MONTHS",DAYS:"DAYS",HAS_JOINED:"HAS_JOINED",SUBMIT:"Submit",SELECT_SLOTS:"Select your slot",BACK:"Back",HERE_TO_UPLOAD:"Click here to upload your file",INVALID_TYPE:"File is of invalid type",TOO_LARGE:"File is too large",CLICK_TO_UPLOAD:"Click here to upload your file",ADD_FILES:"Add Files",UPLOADING:"Uploading",COUNTRY_PLACEHOLDER:"Type your country name here..",BOT:"Bot",JANUARY:"January",FEBRUARY:"February",MARCH:"March",APRIL:"April",MAY:"May",JUNE:"June",JULY:"July",AUGUST:"August",SEPTEMBER:"September",OCTOBER:"October",NOVEMBER:"November",DECEMBER:"December",SUNDAY:"Sunday",MONDAY:"Monday",TUESDAY:"Tuesday",WEDNESDAY:"Wednesday",THURSDAY:"Thursday",FRIDAY:"Friday",SATURDAY:"Saturday",EXPECTS:"Expects",SOMETHING_WENT_WRONG:"Somethig went wrong",MORE_OPTIONS:"More Options",SEND_CHAT_TRANSCRIPT:"Send Chat Transcript",UPLOAD_COMPLETE:"Upload complete",FILE_UPLOAD_HEADER:"Upload files",FILE_ERRORS:{typeError:"FILE_TYPE_ERROR",sizeError:"FILE_SIZE_ERROR",maxFilesError:"MAX_FILE_ERROR"},NO_SLOTS_AVAILABLE:"No slots available for this day",SHOW_MORE:"Show more",BOOK_MEETING:"Book a meeting",MEETING_BOOKED:"MEETING BOOKED",MEETING_ERROR:"ERROR",DISABLE_BOOKING_BTN_TOOLTIP:"This conversation has ended. To book a meeting, start a new conversation.",UNREAD_MESSAGES:"Unread messages",START_NEW_CONVERSATION:"Start a new conversation",CONVERSATIONS:"Conversations",HINT_TEXT:"Send a message",CONVERSATION_END_MSG:"This conversation has ended",FEEDBACK_SUBMIT:"FEEDBACK_SUBMIT",FEEDBACK_CLOSE:"FEEDBACK_CLOSE",ADD_MORE:"Add more",TRANSFER_CHAT_INPROGRESS:"TRANSFER_CHAT_INPROGRESS",TRANSFER_CHAT_COMPLETED:"TRANSFER_CHAT_COMPLETED",MORE_UNREADS:"More unreads"},i=(e,t)=>Object(o.a)().t(e,t),r=()=>[Object(o.a)().t(a.JANUARY),Object(o.a)().t(a.FEBRUARY),Object(o.a)().t(a.MARCH),Object(o.a)().t(a.APRIL),Object(o.a)().t(a.MAY),Object(o.a)().t(a.JUNE),Object(o.a)().t(a.JULY),Object(o.a)().t(a.AUGUST),Object(o.a)().t(a.SEPTEMBER),Object(o.a)().t(a.OCTOBER),Object(o.a)().t(a.NOVEMBER),Object(o.a)().t(a.DECEMBER)],s=()=>[Object(o.a)().t(a.SUNDAY),Object(o.a)().t(a.MONDAY),Object(o.a)().t(a.TUESDAY),Object(o.a)().t(a.WEDNESDAY),Object(o.a)().t(a.THURSDAY),Object(o.a)().t(a.FRIDAY),Object(o.a)().t(a.SATURDAY)]},43:function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return x})),n.d(t,"c",(function(){return R})),n.d(t,"b",(function(){return L}));var o=n(0),a=n.n(o),i=n(2),r=n.n(i),s=n(32),l=n.n(s),c=n(22),d=n(7),u=n(39),p=n(47),_=n(1),f=n(15),v=n(23),m=n(5),g=n(19),b=n(6),y=n(126),h=n(127),O=n(4),E=n(9),w=n(48),S=n(12),A=n(24),T=n(63),I=n(30);function P(e){return function(e){if(Array.isArray(e))return C(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return C(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n{},setMessage:()=>{},setMessages:()=>{},onRestartConversationHanlder:()=>{},previousConversationKeys:!1,emitBotMessage:()=>{},receivedAppointmentBooking:!1,isCalendarDrawerOpen:!1,setIsCalendarDrawerOpen:()=>{},onAppointmentBookingClick:()=>{},hideCalendarPopover:()=>{},isFileUploadPopoverOpen:!1,setIsFileUploadPopoverOpen:()=>{},emitMessageStatusEvent:()=>{}}),R={BOT_MESSAGE:"BOT_MESSAGE",ASSIGNEE_CHANGE:"ASSIGNEE_CHANGE",AGENT_MESSAGE:"AGENT_MESSAGE",FEEDBACK:"feedback",NEW_CONVERSATION:"",FAQ_FEEDBACK:"faq-feedback"},L=0;let k=null,N=null;function B(t){let{children:n}=t;const[i,r]=Object(o.useState)([]),s=Object(o.useRef)({}),[C,j]=Object(o.useState)({}),[M,B]=Object(o.useState)(!1),[U,W]=Object(o.useState)(!1),{preference:G,resetHideInput:F,setTriggerData:K,triggerData:H,payload:z,embedMetaData:V,hideBotOnLoad:Y}=Object(o.useContext)(c.a),[q,J]=Object(o.useState)({isLoading:!1,offset:0,hasMore:!0,isInitialFetch:!1}),{setIsTyping:X,conversationKey:$,setAgentInfo:Z}=Object(o.useContext)(u.a),{setAgentInfo:Q,agentInfo:ee,isAssigned:te,setIsAssigned:ne}=Object(o.useContext)(p.a),{previousConversationKeys:oe,setPreviousConversationKey:ae,currentConversationKey:ie,setCurrentConversationKey:re,sendCustomerDetails:se,setSessionData:le,isOpen:ce,currentBotPublishKey:de,connectionKey:ue,newSessionRequiredData:pe,javascriptExectionMap:_e}=Object(o.useContext)(v.a),{handleLastMessage:fe,readConversationMessage:ve,currentActiveScreen:me,setConversationWiseReadCount:ge,conversationWiseUndreadCounts:be,currentActiveScreenRef:ye,messageTriggeredInPopup:he,totalConversationCount:Oe}=Object(o.useContext)(w.a),Ee=Object(o.useRef)(null),we=Object(o.useRef)(ie),Se=Object(o.useRef)(pe),Ae=Object(o.useRef)(null),Te=Object(o.useRef)(null),[Ie,Pe]=Object(o.useState)(!0),Ce=Object(o.useRef)(G),je=Object(o.useRef)(Ie),De=new h.a,Me=Object(o.useRef)(De).current,[xe,Re]=Object(o.useState)(!1),Le=Object(o.useRef)(null),ke=Object(o.useRef)(null),[Ne,Be]=Object(o.useState)(!1),Ue=Object(o.useRef)(!1),We=Object(o.useRef)(new AbortController),Ge=Object(o.useRef)(-1),Fe=Object(o.useRef)(!1),Ke=Object(o.useRef)([]),He=Object(o.useRef)([]),ze=e=>{Le.current=e,Re(!0)},Ve=()=>{Le.current=null,Re(!1)};Object(o.useEffect)(()=>{!oe[$]&&$&&j(e=>D(D({},e),{},{conversation_id:$}))},[$]),Object(o.useEffect)(()=>{Se.current=pe},[pe]),Object(o.useEffect)(()=>{we.current=ie},[ie]),Object(o.useEffect)(()=>{Ce.current=G,G&&Pe(!G.appearance.is_hide_input_disabled)},[G]),Object(o.useEffect)(()=>{je.current=Ie},[Ie]),Object(o.useEffect)(()=>(window.addEventListener(E.b,qe),()=>{window.removeEventListener(E.b,qe)}),[]),Object(o.useEffect)(()=>{Ee.current&&We.current&&(We.current.abort(),We.current=new AbortController,Ue.current=!1),ce&&Oe&&Xe(we.current,!0)&&i&&i.length&&it(P(i).reverse(),we.current,"read"),Ee.current=ce},[ce]),Object(o.useEffect)(()=>{if(!ce||me===A.b.LIST){Fe.current=!1,Ge.current=-1;const e=i.map(e=>D(D({},e),{},{read_by_visitor_at:!0}));r(P(e))}},[ce,me]);const Ye=(e,t,n)=>{const o=G&&G.onboardingPreview;return{visitor_key:G.uuid,is_live_mode:Object(b.i)()===I.a.PUBLISH&&!o,web_url:"".concat(null!=z&&z.web_url?null==z?void 0:z.web_url:Object.keys(V).length?Object(b.e)():window.location.href),payload:z,is_text_mode:G.is_text_mode||!1,system:{timezone:G.timezone,os:Object(b.d)(),browser:Object(b.b)(),browserLanguage:window.navigator.language,referrerUrl:Object(b.e)()},bot_publish_key:G.bot_publish_key,connection_key:Object(m.t)(),conversation_key:n||we.current,status:{event:e,timestamp:t}}},qe=(e,t)=>{K({trigger:{type:"",message:""},isInitialTriggerPerformed:!1}),setTimeout(()=>{var n,o;const a=t?{text:(null===(n=t.payload)||void 0===n||null===(o=n.payload)||void 0===o?void 0:o.text)||"",media:""}:{text:e.detail.text||"",media:{url:e.detail.media||null}};Object(f.b)(),K({trigger:{type:"popup_message",message:a},isInitialTriggerPerformed:!0})},50)},Je=e=>{var t,n,o,a,s,l,c;Ae.current=null,xe&&Ve(),Ne&&Be(!1);const d=(null==e||null===(t=e.payload)||void 0===t?void 0:t.type)&&m.g.includes(e.payload.type),u=e;u.read_by_visitor_at=Ee.current?me===A.b.DETAIL:null;const p=Ce.current.appearance.is_hide_input_disabled,f=(null==u||null===(n=u.payload)||void 0===n?void 0:n.type)&&u.payload.type===R.FEEDBACK,v=null==e?void 0:e.isSent;p||(void 0===d?Pe(!1):f||Pe(!d)),(null==e||null===(o=e.payload)||void 0===o?void 0:o.type)===_.a.CALENDAR_SLOTS&&2===(null==e||null===(a=e.payload)||void 0===a?void 0:a.version)?xe||ze(e):Ve(),!e.isSent||Ce.current.appearance.is_hide_input_disabled===Ce.current.appearance.is_hide_input_disabled_originalValue||ee||te||F(Ce.current.appearance.is_hide_input_disabled_originalValue),u.id=Object(m.t)();const g=!u.isSent;j(e=>({id:Object(m.t)(),current_index:u.current_index||e.current_index||0,end_dialog_sequence:u.end_dialog_sequence||e.end_dialog_sequence||0,conversation_id:u.conversation_id||e.conversation_id||null,session_id:u.session_id||e.session_id||null,unique_user_key:u.unique_user_key||e.unique_user_key||null,isSocketInitiated:!!g||e.isSocketInitiated,isClosed:i.some(e=>{var t;return null===(t=e.payload)||void 0===t?void 0:t.is_closed})})),g&&!k&&X(!1,!0),null!==(s=u.payload)&&void 0!==s&&s.is_closed&&W(!0);const b=((null===(l=u.payload)||void 0===l?void 0:l.payload)||{}).wait_timeout;ke.current&&(null==e||null===(c=e.sender)||void 0===c?void 0:c.type)===S.a.BOT||(b?(we.current!==(null==u?void 0:u.conversation_key)&&we.current!==(null==u?void 0:u.conversation_id)||r([].concat(P(i),[u])),setTimeout(()=>{se(!1,!1,"time_out")},1e3*b)):setTimeout(()=>{we.current!==(null==u?void 0:u.conversation_key)&&we.current!==(null==u?void 0:u.conversation_id)||r(e=>{var t;return(u.payload&&u.payload.type===R.FEEDBACK||null!==(t=u.payload)&&void 0!==t&&t.is_closed)&&(e=e.filter(e=>{var t;return!e.payload||(null===(t=e.payload)||void 0===t?void 0:t.type)!==_.a.FEEDBACK})),v&&(e=e.filter(e=>{var t;return!e.payload||(null==e||null===(t=e.payload)||void 0===t?void 0:t.type)!==_.a.UNREAD})),[].concat(P(e),[u])})},void 0===d?400:0))},Xe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!(t||!he.current||"visible"!==document.visibilityState||Y)||ye.current===A.b.DETAIL&&e===we.current&&"visible"===document.visibilityState&&!Y},$e=e=>{Je(e),(e.payload||{}).is_closed&&(Q(null),Z(null),ne(!1))},Ze=function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const a=i.some(e=>{var t;return null===(t=e.payload)||void 0===t?void 0:t.is_closed});let s={conversation_key:we.current};if(ee||te||n||X(!0,!0),a){const e=Object(m.t)(!0);ae(C.conversation_id),j(e=>D(D({},e),{},{isSocketInitiated:!1})),re(e),r([]),ke.current=null,s={conversation_key:e}}Object(d.a)(D(D({},e),s),o),m.H.includes(null==e||null===(t=e.message)||void 0===t?void 0:t.type)||ge(e=>{const t=e[we.current]||0;return ve(we.current,t+1),D(D({},e),{},{[we.current]:t+1})})},Qe=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;const i=[];if(J(e=>D(D({},e),{},{isInitialFetch:!1})),e.forEach((e,t)=>{if(0!==Ge.current||Fe.current||(Fe.current=!0,i.push({conversation_key:o,id:Object(m.t)(),payload:{type:_.a.UNREAD},timestamp:e.read_by_visitor_at})),e.agent){var r,s;const l=e.agent;(null==l||!l.assigned)&&"Close"!==(null==l||null===(r=l.status)||void 0===r?void 0:r.name)&&Ge.current>0&&(Ge.current-=1),l.status&&"Close"===l.status.name&&0===n&&i.push({conversation_key:o,payload:{is_closed:!0},type:"status",id:Object(m.t)(),timestamp:l.timestamp}),l.isSent=!1,t||n||(l.isLastReceived=!0),(null==l||null===(s=l.message)||void 0===s?void 0:s.type)===_.a.LIST&&(l.message=Object(m.B)(l.message));const c=a[l.created_by];if(c&&(l.sender={email:c.email,id:parseInt(l.created_by,10),first_name:c.name,last_name:"",type:c.user_type,image_url:c.image_url||""}),l.assigned&&!Ce.current.avoidAssigneeChange){const e=a[l.assigned.to.created_by];e&&e.user_type!==S.a.BOT&&(l.payload={assigned:{to:{email:e.email,id:parseInt(l.assigned.to.created_by,10),first_name:e.name,last_name:"",type:e.user_type,image_url:e.image_url||""}},type:_.a.ASSIGNEE_CHANGED})}i.push(Object(m.r)(l,n))}const l=e.user;l&&(l.isSent=!0,Ge.current>0&&null!=e&&e.user&&(Ge.current-=1),i.push(Object(m.r)(l,n)))}),i.length&&i[i.length-1]&&!n){const e=i[i.length-1].message&&i[i.length-1].message.payload||{};j(n=>({id:e.id||n.id||0,current_index:e.current_index||n.current_index||0,end_dialog_sequence:e.end_dialog_sequence||n.end_dialog_sequence||0,session_id:t||n.session_id||null,conversation_id:t||n.conversation_id||null,unique_user_key:G.unique_user_key||n.unique_user_key||null,isSocketInitiated:!1})),i[i.length-1].country_code=e.country_code||""}return i},et=e=>e||(1===Object(b.g)()?Object(b.f)():G.bot_publish_key),tt=e=>{let{text:t,type:n,url:o,temporaryMsg:a,conversationKey:i,botPublishKey:r,popupAvatar:s,assigneeName:l}=e;K(D(D({},H),{},{isTriggerPerformed:!0,trigger:{message:{botPublishKey:r,conversationKey:i,tempMessage:a||"",text:t,media:{type:n,url:o},avatar:s,assignee:l},type:O.b.LAST_MESSAGE}}))},nt=async function(t,n,o){let a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(!G)return;t||J(e=>D(D({},e),{},{isInitialFetch:!0})),J(e=>D(D({},e),{},{isLoading:!!t,shouldStartFetching:!1}));let i="";n&&(i="conversation_key=".concat(n)),t&&Te.current&&Te.current.length&&(i+="".concat(i?"&":"","search_after=").concat(Te.current.join(","))),t||(Ge.current=be[n]||-1);let c=e.env.API_LIMIT||20;Ge.current===c&&(c=(e.env.API_LIMIT||20)+5);try{N=new AbortController;const e=await fetch("".concat(g.b,"v1/conversations/history/bots/").concat(et(o),"/visitors/").concat(G.uuid,"?origin=chat_widget&limit=").concat(c).concat(i?"&":"").concat(i),{credentials:"include",signal:N.signal});N=null;const x=await e.json();Te.current=x.search_after,B(!0);const R=0;if(x.messages_list&&x.messages_list.length){if(s.current=D(D({},s.current),x.users),ge(e=>D(D({},e),{},{[x.conversation_key]:x.total_messages_count})),!t){var u,p,f;const{assignee:e}=x;if(null!=x&&null!==(u=x.assignee)&&void 0!==u&&u.assigned_to&&x.users){const e=x.users[x.assignee.assigned_to];e.user_type!==S.a.BOT&&(Z(e),Q({assignee:{to:{email:e.email,id:e.user_type_id,first_name:e.name,last_name:"",type:e.user_type,image_url:e.image_url}}}))}let t=!1;null!==(p=x.messages_list[0])&&void 0!==p&&p.agent&&null!==(f=x.messages_list[0])&&void 0!==f&&f.agent.status&&(t="Close"===x.messages_list[0].agent.status.name),e&&e.type!==y.a.BOT&&!t&&(F(!0),ne(!0)),le(x.conversation_key),d.e({visitor_key:G.uuid,bot_id:G.bot_lead_id,account_id:G.account_id},()=>{})}if(t){var v,b;const e=(null===(v=document.querySelector("#widget-chat-window"))||void 0===v||null===(b=v.contentWindow)||void 0===b?void 0:b.document).querySelector(".message-container__root"),t=e.scrollHeight;r(e=>[].concat(P(Qe(x.messages_list,x.session_id,1,null,s.current).reverse()),P(e))),e.scrollTop=e.scrollHeight-t+e.scrollTop,setTimeout(()=>{J(e=>D(D({},e),{},{isLoading:!1,shouldStartFetching:!0}))},500)}else{var h,O,E,w;const e=Qe(x.messages_list,x.session_id,R,n,s.current),[t]=e;if(null!==(h=t.payload)&&void 0!==h&&h.is_closed&&!n)return r([]),ke.current=null,setTimeout(()=>{X(!0)},100),void se(!0,!1,"history");try{var A;const e=null==t||null===(A=t.payload)||void 0===A?void 0:A.type;if(!e||e!==_.a.JAVASCRIPT&&e!==_.a.GOOGLE_ANALYTICS)tt(Object(m.v)(D(D({},t),{},{conversation_key:x.conversation_key}),G));else{var I,C,j,M;const n=null==t||null===(I=t.message)||void 0===I||null===(C=I.payload)||void 0===C?void 0:C.script,o=l()(null==t?void 0:t.timestamp).utc().format("YYYY-MM-DDTHH:mm:ss.SSSSSS[+00:00]"),a=Ye("read",o,null==t?void 0:t.conversation_key);_e.current.push(null==t||null===(j=t.payload)||void 0===j||null===(M=j.payload)||void 0===M?void 0:M.id),Object(T.a)(n||"",e===_.a.GOOGLE_ANALYTICS,(function(n){var o,a,i,r;let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var l,c;null!=t&&null!==(o=t.message)&&void 0!==o&&null!==(a=o.payload)&&void 0!==a&&a.id&&(n.id=null==t||null===(l=t.message)||void 0===l||null===(c=l.payload)||void 0===c?void 0:c.id);const d=e===_.a.GOOGLE_ANALYTICS;Ze(D(D({},Se.current),{},{connection_key:Object(m.t)(),message:{type:s?_.a.CALENDLY_RESPONSE:d?_.a.GOOGLE_ANALYTICS_RESPONSE:_.a.JAVASCRIPT_RESPONSE,data:d?{id:null==t||null===(i=t.message)||void 0===i||null===(r=i.payload)||void 0===r?void 0:r.id}:n}}))}),a)}}catch(e){}!t||(null==t||null===(O=t.payload)||void 0===O?void 0:O.type)!==_.a.INPUT_TYPE&&(null==t||null===(E=t.payload)||void 0===E?void 0:E.type)!==_.a.PHONE&&(null==t||null===(w=t.payload)||void 0===w?void 0:w.type)!==_.a.NUMBER||x.is_human_handover_successful||F(!0),r(e.reverse()),setTimeout(()=>{J(e=>D(D({},e),{},{shouldStartFetching:!0}))},500),ve(x.conversation_key,x.total_messages_count),it(P(e).reverse(),null==x?void 0:x.conversation_key,"read"),ge(e=>D(D({},e),{},{[x.conversation_key]:x.total_messages_count}))}}else t?J(e=>D(D({},e),{},{isLoading:!1,shouldStartFetching:!1})):a?J(e=>D(D({},e),{},{isInitialFetch:!1})):(J(e=>D(D({},e),{},{isInitialFetch:!1})),X(!0),r([]),ke.current=null,se(!0,!0,"initialization-history"))}catch(e){X(!0),J(e=>D(D({},e),{},{isLoading:!1}))}},ot=()=>{i.length&&we.current&&ye.current===A.b.DETAIL&&ce&&"visible"===document.visibilityState&&it(P(i).reverse(),we.current,"read")},at=()=>{i&&i.length&&we.current&&ye.current===A.b.DETAIL&&it(P(i).reverse(),we.current,"read")};Object(o.useEffect)(()=>(document.addEventListener("visibilitychange",ot),window.addEventListener("emitReadAllMessagesEvent",at),()=>{document.removeEventListener("visibilitychange",ot),window.removeEventListener("emitReadAllMessagesEvent",at)}),[i,ye,ce]);const it=(e,t,n)=>{const[o]=e;let a="delivered",i=null==o?void 0:o.timestamp;l()(i,void 0,!0).isValid()&&"number"==typeof i&&(i=l()(i).utc().format("YYYY-MM-DDTHH:mm:ss.SSSSSS[+00:00]")),n&&(a=n);const r=Ye(a,i,t);Object(d.a)(r,!1,L)},rt=(e,t,n)=>{let o="delivered";const a=null==e?void 0:e.conversation_key;if(n&&(o=n),(e=>{var t,n;return(null==e||null===(t=e.sender)||void 0===t?void 0:t.type)===S.a.BOT||(null==e||null===(n=e.sender)||void 0===n?void 0:n.type)===S.a.AGENT||0===Object.keys(e).length})(e)&&function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"message";if((null==e||null===(t=e.sender)||void 0===t?void 0:t.type)===S.a.VISITOR)return!1;if(m.x.includes(null==e?void 0:e.payload.type))return!1;switch(n){case R.ASSIGNEE_CHANGE:case _.a.STATUS:case R.FAQ_FEEDBACK:return!1;default:return!0}}(e,t)){const t=D(D({},Se.current),{},{connection_key:Object(m.t)(),conversation_key:a,status:{event:o,timestamp:l()(null==e?void 0:e.timestamp).utc().format("YYYY-MM-DDTHH:mm:ss.SSSSSS[+00:00]")}});delete t.message,Object(d.a)(t,!1,L)}},st=(e,t)=>{var n;if((null==e||null===(n=e.sender)||void 0===n?void 0:n.type)!==S.a.VISITOR)switch(t){case R.ASSIGNEE_CHANGE:case O.a.ASSIGNEE_CHANGED:(e=>{if(We.current&&(We.current.abort(),We.current=new AbortController,Ue.current=!1),ne(!0),F(!0),ke.current=!0,e.payload&&e.payload.assignee&&e.payload.assignee.to.id){const t=D(D({},C),{},{payload:{timestamp:e.timestamp,assigned:e.payload.assignee,type:"assignee-change"},conversation_key:e.conversation_key,bot_id:e.bot_id,user_message:e.user_message||null,bot_title:e.bot_title||null,visitor_name:e.visitor_name||null,is_new_conversation:e.is_new_conversation||!1,global_channel_name:e.global_channel_name||null});if(t.payload.type="assignee-change",Q(e.payload),Ce.current.avoidAssigneeChange)return;Je(t)}else{const t=D(D({},C),{},{payload:D(D({},e.sender),{},{payload:{type:"text",text:""}}),conversation_id:e.conversation_key,session_id:e.conversation_key,timestamp:e.timestamp});if(t.payload.type="text",t.payload.payload.text="",t.payload.timestamp=e.timestamp,Ce.current.avoidAssigneeChange)return;Je(t)}k||X(!1,!0)})(e);break;case R.AGENT_MESSAGE:(e=>{if("agent"===e.payload.type){const t=D({message:e.sender,conversation_key:e.conversation_key,bot_id:e.bot_id,user_message:e.user_message||null,bot_title:e.bot_title||null,visitor_name:e.visitor_name||null,is_new_conversation:e.is_new_conversation||!1,global_channel_name:e.global_channel_name||null},C);t.message.type=_.a.TEXT,t.message.text=t.payload.text,Je(t)}})(e);break;default:$e(e)}else{var o;const t=i[i.length-1];if(!t)return;if(t.connection_key===e.connection_key)return;if("appointment_booking.response"===(null==e||null===(o=e.message)||void 0===o?void 0:o.type)){var a;const t=null==e||null===(a=e.message)||void 0===a?void 0:a.data,n=i.findIndex(e=>{var n,o;return(null==e||null===(n=e.payload)||void 0===n||null===(o=n.payload)||void 0===o?void 0:o.id)===t.id}),o=P(i),s=o[n];return t.is_booking_failed?(s.payload.payload.is_booking_confirmed=!1,s.payload.payload.is_booking_failed=!0):t.is_booking_confirmed&&(s.payload.payload.is_booking_confirmed=!0),s.payload.payload.variables=t.variables,s.payload.payload.visitor_timezone=t.visitor_timezone,o[n]=s,void r(P(o))}if("file_upload.response"===e.message.type){const t={version:2,files:e.message.data.files,type:_.a.FILE_RESPONSE},n=Object(m.o)({conversation_id:e.conversation_id,payload:{payload:t,type:_.a.FILE_RESPONSE},timestamp:(new Date).toISOString(),id:Object(m.t)()});return void $e(n)}const n=Object(m.o)({conversation_id:e.conversation_id,payload:{payload:{type:_.a.TEXT,wait_timeout:0,text:e.message.data.body},type:_.a.TEXT},timestamp:(new Date).toISOString(),id:Object(m.t)()});$e(n)}},lt=(e,t)=>{var n;const o=e.conversation_key;let a=e;a=Object(m.C)(a,null==e||null===(n=e.payload)||void 0===n?void 0:n.type),fe(a,t),Xe(o)&&rt(a,t,"read"),o===we.current&&st(a,t)},ct=e=>{Me.enqueue(e),k||dt(0,G.appearance.typing_delay,null)},dt=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,o=arguments.length>2?arguments[2]:void 0;var a;if(!Me.getList().length)return m.x.includes(null==o||null===(a=o.payload)||void 0===a?void 0:a.type)||X(!1),void(k=null);if(Me.getList().length&&Me.getFirstItem()){const o=Me.getFirstItem(),a=Me.peek(),i=a&&a.type===O.a.STATUS_CHANGED&&2===Me.size(),{messageDelay:r,shouldAppendWithMsg:s,message:l}=Object(m.h)(o,G.appearance.typing_delay,i);l.conversation_key!==we.current||ye.current!==A.b.DETAIL||l.type===O.a.FAQ_FEEDBACK&&a.type===O.a.FAQ_FEEDBACK||X(!0,!0),k=setTimeout(()=>{s&&l&<(l,l.type),Me.dequeue(),e(r,n,a)},t)}};Object(o.useEffect)(()=>{Me.clear(),k=null,X(!1)},[ke.current]),Object(o.useEffect)(()=>{let e=!1;if(G){const t=function(t,n){var o;let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=t.conversation_key;let r=t;if(r=Object(m.C)(r,null==t||null===(o=t.payload)||void 0===o?void 0:o.type),!e||a){if(fe(r,n),Xe(i)&&rt(r,n,"read"),i!==we.current)return;st(r,n)}},n=e=>{Me.addList(e),k||dt(0,G.appearance.typing_delay,null)};d.k(e=>t(e,R.BOT_MESSAGE)),d.i(e=>t(e,R.BOT_MESSAGE)),d.j(e=>{var o;if(Array.isArray(e))return it(P(e).reverse(),null===(o=e[0])||void 0===o?void 0:o.conversation_key,"delivered"),void n(e,G.appearance.typing_delay);rt(e,R.BOT_MESSAGE,"delivered"),t(e,R.BOT_MESSAGE)}),d.l(e=>{var t,o,a,i,r,s,l,c,d,u,p,f,v,m;let g=e;if((1!==e.length||(null===(t=e[0])||void 0===t?void 0:t.type)!==O.a.TYPING)&&(1!==e.length||(null===(o=e[0])||void 0===o?void 0:o.type)!==O.a.ASSIGNEE_CHANGED||null!=e&&null!==(a=e.payload)&&void 0!==a&&a.assignee)){var b,y;if(![_.a.AI_STUDIO,_.a.STREAMING].includes(null===(i=e[1])||void 0===i||null===(r=i.payload)||void 0===r?void 0:r.type))it(P(e).reverse(),null===(b=e[0])||void 0===b?void 0:b.conversation_key,"delivered");if(4===(null==e?void 0:e.length)&&((null===(s=e[1])||void 0===s||null===(l=s.payload)||void 0===l||null===(c=l.payload)||void 0===c?void 0:c.sub_type)===_.a.AI_STUDIO_RESPONSE||(null===(d=e[1])||void 0===d||null===(u=d.payload)||void 0===u||null===(p=u.payload)||void 0===p?void 0:p.sub_type)===_.a.STREAMING_RESPONSE)&&null!==(f=e[1])&&void 0!==f&&null!==(v=f.payload)&&void 0!==v&&null!==(m=v.payload)&&void 0!==m&&m.is_ignore)Xe(null===(y=e[1])||void 0===y?void 0:y.conversation_key)&&rt(e[1],e[1].type,"read"),g=e.splice(2,1),F(!0);n(g,G.appearance.typing_delay)}}),d.i(e=>t(e,R.ASSIGNEE_CHANGE)),d.n(e=>{ct(D(D({},e),{},{type:O.a.STATUS_CHANGED}))}),d.m(e=>{ct(D(D({},e),{},{type:O.a.FAQ_FEEDBACK}))}),d.q(e=>{e.connection_key!==ue&&ve(e.conversation_key,0,!1)})}return()=>{e=!0}});const ut={messages:i,conversationDetails:C,setMessage:$e,setMessages:e=>{X(!1),r(e)},setConversationDetails:e=>{j(e)},onRestartConversationHanlder:()=>{Me.getList().length&&(Me.clear(),k=null),W(!0),ne(!1),Pe(!Ce.current.appearance.is_hide_input_disabled_originalValue),F(Ce.current.appearance.is_hide_input_disabled_originalValue),Q(null),ae(C.conversation_id),j(e=>D(D({},e),{},{isSocketInitiated:!1})),r([]),ke.current=null},previousConversationKeys:oe,emitBotMessage:Ze,showFeedbackModal:U,setShowFeedbackModal:W,fetchHistory:nt,isHistoryFetched:M,historyData:q,handleFetchMoreHistory:()=>{nt(!0,we.current,de)},setHistoryData:J,hideInput:Ie,loadSelectedConversationHistory:(e,t)=>{if(e===we.current)return r([]),ke.current=null,void nt(void 0,e,t);B(!1),r([]),ke.current=null,nt(void 0,e,t)},cancelFetchHistoryRequest:()=>{N&&N.abort()},isCalendarDrawerOpen:xe,setIsCalendarDrawerOpen:Re,onAppointmentBookingClick:ze,hideCalendarPopover:Ve,appointmentBookingMsgRef:Le,appointmentBookingStopScrollRef:Ae,isFileUploadPopoverOpen:Ne,setIsFileUploadPopoverOpen:Be,isStreamingInProcess:Ue,streamingController:We,openRef:Ee,numberOfUnreads:Ge,unreadBadgeAdded:Fe,whatsappFlowflowExecutionCompletedMap:Ke,whatsappCatalogExecutionCompletedMap:He,emitMessageStatusEvent:rt};return a.a.createElement(x.Provider,{value:ut},n)}B.propTypes={children:r.a.node},t.d=B}).call(this,n(44))},45:function(e,t,n){"use strict";t.a={colors:{primary:"#0f67f6",grey:"#f7f7f7",white:"#ffffff",text:"#464646",primaryText:"#464646",brownGrey:"#a7a7a7",buttonBorder:"#d1d1d1",black:"#000000",inputBorder:"#dddddd",errorBorder:"#f6210f",errorBackground:"#ffd6d3",inputLabelBackground:"#e5efff",closeIconGrey:"#e6e6e6",onlineBackground:"#4dff6f",onlineBorder:"#2274f8",faintedWhite:"rgba(255, 255, 255, 0.5)",overlay:"rgba(0, 0, 0, 0.4)",darkOverlay:"rgba(0, 0, 0, 0.85)",inputSecondaryBorder:"#d1d1d1",hyperlink:"#0b69ff",brownGreyDark:"#b1b8bb",labelGrey:"#a3a3a3",darkGrey:"#e8e9ef",playBtnLabel:"#707070",volumeControlBackground:"#efefef",volumeControlProgress:"#6b6b6b",videoPreviewBackground:"#f9f9f9",noteMessageBackground:"#f5be4f",ratingColor:"#f1b000",ratingOutlineColor:"#858585",success:"#13be66",tooltipColor:"#d3d3d3",tooltipTextColor:"#101010",dividerColor:"#eeeff3",disabledColor:"#545454",lightGray:"#d9d9d9",volumeSliderColor:"#111927"},radius:{message:"12px",messageInput:"10px",button:"15px",metaLabel:"5px",filePreview:"5px",input:"5px",roundShape:"50%"},sizes:{chatWindowHeight:644,chatWindowWidth:360,chatBubble:50,headerHeight:70,largeHeaderHeight:140,poweredByHeight:40,sliderHeight:"2px",sliderWidth:"2px"},fonts:{fontStack:"SF UI Display, -apple-system, system-ui, sans-serif",largeText:"18px",mediumText:"14px",extraMedium:"13px",smallText:"12px",tinyText:"10px",extraSmallText:"8px",conversationListText:"11px",labelText:"13px",labelFont:"500",mediumFont:"400",thickFont:"600",mediumLineHeight:1.83,smallLineHeight:1.2,tinyLineHeight:1,messageInputLineHeight:1.14,cardSubtitleHeight:1.5,tickerLineHeight:1.36,filePreviewTextHeight:1.25,filePDFTextHeight:1.6},zIndexes:{popupLevel:110,headerLevel:120,footerLevel:60,headerMenuLevel:70,chatBubble:2147483628},positions:{chatBubbleBottom:30,chatBubbleHorizontalSpace:30,floatingMessageHorizontalSpace:25,chatBubbleTop:"unset",chatBubbleLeft:"unset"}}},46:function(e,t,n){"use strict";var o=n(43);n.d(t,"a",(function(){return o.a})),n.d(t,"b",(function(){return o.d}))},47:function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return c}));var o=n(0),a=n.n(o),i=n(2),r=n.n(i);const s=Object(o.createContext)({agentInfo:null,setAgentInfo:()=>{},setIsAssigned:()=>{},isAssigned:!1});function l(e){let{children:t}=e;const[n,i]=Object(o.useState)(null),[r,l]=Object(o.useState)(!1);return a.a.createElement(s.Provider,{value:{agentInfo:n,setAgentInfo:i,setIsAssigned:l,isAssigned:r}},t)}l.propTypes={children:r.a.node};var c=l},48:function(e,t,n){"use strict";var o=n(24);n.d(t,"b",(function(){return o.c})),n.d(t,"a",(function(){return o.a}))},5:function(e,t,n){"use strict";(function(e){n.d(t,"e",(function(){return C})),n.d(t,"g",(function(){return D})),n.d(t,"a",(function(){return N})),n.d(t,"G",(function(){return B})),n.d(t,"u",(function(){return U})),n.d(t,"t",(function(){return W})),n.d(t,"o",(function(){return K})),n.d(t,"p",(function(){return H})),n.d(t,"j",(function(){return z})),n.d(t,"F",(function(){return V})),n.d(t,"z",(function(){return Y})),n.d(t,"n",(function(){return q})),n.d(t,"k",(function(){return J})),n.d(t,"s",(function(){return X})),n.d(t,"w",(function(){return $})),n.d(t,"q",(function(){return Z})),n.d(t,"m",(function(){return ee})),n.d(t,"l",(function(){return ne})),n.d(t,"r",(function(){return oe})),n.d(t,"B",(function(){return ae})),n.d(t,"C",(function(){return ie})),n.d(t,"d",(function(){return re})),n.d(t,"D",(function(){return le})),n.d(t,"y",(function(){return ce})),n.d(t,"h",(function(){return de})),n.d(t,"v",(function(){return ue})),n.d(t,"b",(function(){return pe})),n.d(t,"c",(function(){return _e})),n.d(t,"x",(function(){return fe})),n.d(t,"H",(function(){return ve})),n.d(t,"E",(function(){return me})),n.d(t,"f",(function(){return ge})),n.d(t,"A",(function(){return he})),n.d(t,"i",(function(){return Oe}));var o=n(0),a=n.n(o),i=(n(59),n(90)),r=n(202),s=n(8),l=n(86),c=n(3),d=n(91),u=n(34),p=n(4),_=n(1),f=n(35),v=n(12),m=n(29),g=n(42);const b=["children"],y=["children"],h=["children"],O=["children"];function E(){return(E=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function A(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,o=new Array(t);ne,formatHref:e=>e,ignoreTags:["iframe","video","img","audio","a","voice"],nl2br:!1,tagName:"a",target:{url:"_blank"},validate:{url:e=>"localhost"!==e}},D=["text","name","email","phone","number"],M="mp4",x="flv",R="mkv",L="3gp",k="m4a",N={MP3:".mp3",OGG:".ogg",WAV:".wav"},B=async(e,t,n)=>{try{const o=new Date;o.setTime(o.getTime()+24*t*60*60*1e3);const a=o.toUTCString();document.cookie="".concat(e,"=").concat(n,";samesite=none;secure;domain=").concat(window.location.hostname.replace(".www",""),";path=/;expires=").concat(a)}catch(e){console.log("cookies are blocked")}},U=e=>{try{const t=q(document.cookie);return t[e]?t[e]:null}catch(e){return null}};function W(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=new Date,n=Math.floor(t/1e3);return"".concat(Object(r.a)().replace(/-/g,"")).concat(e?n:"")}function G(e){return!!new RegExp(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z0-9]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g).test(e)}const F=e=>"<".concat(e[1]),K=e=>({conversation_id:e.conversation_id||e.conversation_id,action:"",country_code:"",current_index:0,payload:e.payload,sender:{},timestamp:e.timestamp,session_id:"",ok:!0,id:e.id,isSent:!0}),H=(e,t,n)=>e.split(t).join(n);function z(e){if(e.match(f.a.IMG_TAG)||e.match(f.a.IFRAME_TAG)||e.match(f.a.AUDIO_TAG)||e.match(f.a.VIDEO_TAG))return e;if(e.match(m.b.ANONYMOUS_IMAGE_TAG))return e=H(e,"<","<"),e=H(e,">",">");try{return e=e.replace(/<\d|<\s/g,F),Object(i.a)(e,j)}catch(e){}const t=f.a.EMAIL_PATTERN,n=e.match(t),o=e.match(f.a.EMAIL_MAILTO_PATTERN);if(null!=n)for(let t=0;t').concat(n[t],"");e=e.replace(n[t],a)}}const a=f.a.WITH_PROTOCOL_PATTERN,r=f.a.WITHOUT_PROTOCOL_PATTERN,s=(e=e.replace(a,'$1')).split(".");return s[1]&&(Q(s[1])||Q(s[1][0]))?e:e=e.replace(r,'$1')}function V(e){window.postMessage(JSON.stringify(e),"*")}function Y(e){try{return JSON.parse(e),!0}catch(e){return!1}}function q(e){e=e.split("; ");const t={};for(let n=0;n{const n=function(e){switch(e){case".pdf":return"application/pdf";case".csv":return["text/csv",".csv","text/comma-separated-values"];case".jpg":return"image/jpeg";case".png":return"image/png";case".doc":return[".doc","application/msword"];case".docx":return[".docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"];case".ppt":return[".ppt","application/vnd.ms-powerpoint"];case".xls":return"application/vnd.ms-excel";case".xlsx":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case".mp4":return"video/mp4";case".webm":return"video/webm";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".ogg":return["video/ogg","audio/ogg"];case".3gp":return["video/3gpp","audio/3gpp"];default:return""}}(t);if(Array.isArray(n)){const t=[];return n.map(e=>t.push(e)),[].concat(I(e),t)}return[].concat(I(e),[n])},[]):[]}function $(e,t,n){const o=(e-t)/n;let a=t;const i={};for(i[Number(t.toFixed(2))]="";a<=e;a+=o)a!==t&&a!==e&&(i[Number(a.toFixed(2))]="");return i[Number(e.toFixed(2))]="",i}function Z(e,t,n){try{return"$"===e?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(t):"€"===e?new Intl.NumberFormat("en-US",{style:"currency",currency:"EUR"}).format(t):"₹"===e?new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR"}).format(t).replace(/\s/g,""):"£"===e?new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP"}).format(t):"°F"===e?"".concat(t,"°F"):"°C"===e?"".concat(t,"°C"):t}catch(n){return"".concat(t).concat(e)}}function Q(e){return!isNaN(e)}const ee=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return"string"==typeof e&&G(e)?!!(e.endsWith(M)||e.endsWith(x)||e.endsWith(k)||e.endsWith(L)||e.endsWith(R)):""},te=e=>{try{const t=e.split("/");if(t[t.length-1])return t[t.length-1]}catch(e){}return""},ne=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"pdf";if("string"!=typeof e||!G(e))return!1;if(e.endsWith(n)){if(t){const t=te(e);return t&&t.includes(n)?t:e}return e}return""},oe=(e,t)=>{if(e.stopScroll=t,!e.message)return e;let n={};try{n=JSON.parse(""===e.message.text?"{}":e.message.text),n=A(A({},n),{},{title:n.message||n.title||""})}catch(t){n=A(A({},e.message),{},{title:n.message||n.title||n.text||""})}let{type:o}=e.message;if("form"===o||"form.response"===o){const t=e=>{try{const t=/\(([^)]+)\)/;if("input"===e.trim())return"text";return t.exec(e)[1]}catch(t){return e}};let o="in";try{o=e.message.country_code}catch(e){}n=A(A({},n),{},{type:_.a.FORM,fields:n.fields.map(e=>A(A({},e),{},{type:t(e.type)||"input"})),extra:{country_code:o}})}"file"===o&&(n=A(A({},n),{},{type:_.a.FILE}),o=_.a.FILE),"options"===o&&(o=_.a.OPTIONS,n=A(A({},n),{},{buttons:n.options.map(e=>A(A({},e),{},{title:e.text})),type:_.a.OPTIONS,title:n.text})),"cardview"===o&&(o=_.a.CARD_VIEW,n=A(A({},n),{},{cards:n.items.map(e=>A(A({},e),{},{description:e.subtitle,buttons:(e.options||[]).map(e=>A(A({},e),{},{title:e.text}))})),type:_.a.OPTIONS,title:n.text})),"phone"===o&&(n=A(A({},n),{},{extra:{country_code:n.country_code}})),o===_.a.JAVASCRIPT&&(n=A({},e.message.payload)),o===_.a.CALENDAR_SLOTS&&(n=A({},e.message.payload));const a=e.sender?e.sender:{};return A(A({},e),{},{id:W(),payload:A(A({},e.message),{},{type:o,payload:A(A({},n),{},{text:e.message.text,type:o})}),sender:a})},ae=e=>{const t=[];return e.list.sections.forEach(e=>{e.items.map(e=>t.push({text:e.title,next_dialog:e.next_dialog}))}),A(A({},e),{},{text:e.title,type:"options",options:t,version:2})},ie=(e,t)=>{switch(t){case _.a.LIST:return(e=>{const t=[],{header:n,title:o,footer:a,validation:i,key:r}=e.payload.payload;return e.payload.payload.list.sections.forEach(e=>{e.items.map(e=>t.push({title:e.title,next_dialog:e.next_dialog}))}),A(A({},e),{},{payload:{type:_.a.OPTIONS,payload:{version:2,header:n,title:o,footer:a,buttons:t,validation:i,key:r},wait_on_visitor_input:e.payload.wait_on_visitor_input}})})(e);default:return e}},re=["image","video","document","audio","voice"],se=(e,t)=>{switch(e){case"image":return'msg');case"video":return'');case"voice":case"audio":return'